<script>
	import Vue from 'vue';
	import { wxSlientLogin } from '@/common/api/auth.js';
	export default {
		onLaunch: function() {
			uni.getSystemInfo({
				success: function(e) {
					// #ifndef MP
					Vue.prototype.StatusBar = e.statusBarHeight;
					Vue.prototype.CustomBar = e.statusBarHeight + 55;
					// #endif
					// #ifdef MP-WEIXIN
					Vue.prototype.StatusBar = e.statusBarHeight;
					let custom = wx.getMenuButtonBoundingClientRect();
					Vue.prototype.Custom = custom;
					Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight + 10;
					// #endif		
				}
			})
			// this.silentLogin()
		},
		onShow: function() {
			
		},
		onHide: function() {			
			
		},
		methods: {
			silentLogin() {
				const that = this
				// #ifdef MP-WEIXIN
				wx.login({
					success: loginRes => {
						wxSlientLogin({ code: loginRes.code }).then(silentLoginRes => {
							if(silentLoginRes&&silentLoginRes.code==1) {
								that.$store.dispatch('user/login', silentLoginRes.data)
							} else {
								that.$store.dispatch('user/setLogin', true);
							}
						})
					}
				})
				// #endif
			}
		}
	}
</script>

<style>
	@import "static/css/main.css";
	@import "static/css/icon.css";
</style>
